<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
            var reg1 = /^\d{6}/g;
            var reg2 = new RegExp("\\d{6}","g");
            console.log(reg1,reg2);
            var str1 = "1234567";
            var str2 = "abc34567890"
            var r1 = reg2.test(str1);
            reg2.lastIndex = 0;
            console.log(r1,reg2.lastIndex);
            var r2 = reg2.test(str1);
            console.log(r2,reg2.lastIndex);


    </script>
</head>
<body>
    
</body>
</html>